package ru.st.selenium;

import java.net.MalformedURLException;
import java.net.URL;

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class LocalAndRemote {
	
	@Test
	public void runInLocalBrowser() {
		WebDriver driver = new FirefoxDriver();
		driver.get("http://selenium2.ru");
		driver.quit();
	}
	
	@Test
	public void runRemotelyOnLocalHost (){
		WebDriver driver = new RemoteWebDriver(DesiredCapabilities.firefox());
		driver.get("http://selenium2.ru");
		driver.quit();
	}
	
	@Test
	public void runRemotelyOnRemoteHost () throws MalformedURLException{
		WebDriver driver = new RemoteWebDriver(new URL("http://169.254.0.56:4444/wd/hub"), 
				DesiredCapabilities.firefox());
		driver.get("http://selenium2.ru");
		driver.quit();
	}
	
	@Test
	public void runRemotelyInCloud () throws MalformedURLException{
		WebDriver driver = new RemoteWebDriver(new 
				URL("http://serjteplov:d0450709-c7ca-490c-a368-1609d99d43d5@ondemand.saucelabs.com:80/wd/hub"), 
				DesiredCapabilities.firefox());
		driver.get("http://selenium2.ru");
		driver.quit();
	}
}
